using System;

public abstract class AbsHFSingleRunTime<T> : IHFSingle
    where T : AbsHFSingleRunTime<T>,new()
{
    static T m_Instance;

    public event Action<IHFRecycle> OnAfterRecycleHandler;

    public static T Instance {
        get {

            if (m_Instance == null ) {
                m_Instance = new T();
                m_Instance.OnAfterCreateInstance();
                HFSingleSingleManager.AddSingle<T>(m_Instance);
            }
            return m_Instance;
        }
    }

    /// <summary>
    /// Recycle
    /// </summary>
    public void Recycle()
    {
        OnRecycle();
    }

    /// <summary>
    /// OnRecycle
    /// </summary>
    protected virtual void OnRecycle() { }

    /// <summary>
    /// AfterCreateInstance
    /// </summary>
    protected virtual void OnAfterCreateInstance() {

    }
}

